package com.xwolf.os;

import com.xwolf.os.Domain.MyBean;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * @author ming
 * @Description:
 * @create 2018-08-24 9:32 PM
 **/
@Log4j
@Component
public class Runner implements CommandLineRunner {

    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    @Qualifier("user")
    MyBean mybean;

    @Override
    public void run(String... args) throws Exception {
        String[] names = applicationContext.getBeanNamesForType(MyBean.class);
        log.info(">>>>>Get bean names:");
        Arrays.stream(names).forEach(e->log.info(">>>>>" + e));
        log.info("mybean is:" + mybean);

    }

}
